import Vue from 'vue';
import VueRouter from 'vue-router';
import Home from '../components/Home.vue';
import Login from '../components/Login.vue';
import AdminIndex from '../components/admin/AdminIndex';
import Register from '../components/Register';
// import HelloWorld from '@/components/HelloWorld'

Vue.use(VueRouter)

const routes = [{
        path: '/',
        name: 'Default',
        redirect: '/home',
        component: Home
    },
    {
        path: '/home',
        name: 'Home',
        component: Home,
        //home页面不需要被访问
        redirect: '/index',
        children: [{

        }]

    },
    {
        path: '/login',
        name: 'Login',
        component: Login
    },
    {
        path: '/register',
        name: 'Register',
        component: Register
    },
    {
        path: '/admin',
        name: 'Admin',
        component: AdminIndex,
        meta: {
            requireAuth: true
        }
    }
]

const router = new VueRouter({
        mode: 'history',
        routes
    })
    //用于创建默认路由
export const createRouter = new VueRouter({
    mode: 'history',
    routes
})
export default router